package 代码记录.校招笔试真题.笔试真题_2023.极致游戏;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zx
 * @create 2023-02-23 21:51
 * 10%
 */
public class Test1 {
    public static void main(String[] args) {
        String s = "a123bc34d8ef34";
        System.out.println(numDifferentIntegers(s));
    }
    public static int numDifferentIntegers (String word) {
        char[] arr = word.toCharArray();
        String temp = "";
        for(int i = 0;i < arr.length;i++){
            if(arr[i] >= '0' && arr[i] <= '9'){
                continue;
            }else{
                arr[i] = ' ';
            }
            temp += arr[i];
        }
        String[] s = temp.split(" ");
        Set<Integer> set = new HashSet<>();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < s.length;i++){
            String ss = s[i];
            int a = Integer.parseInt(ss);
            if(set.contains(a)){
                continue;
            }else{
                set.add(a);
                list.add(a);
            }
        }
        int res = 0;
        for(int i = 0;i < list.size();i++){
            res += list.get(i);
        }
        return res;
    }
}
